from data import dataProcess
from vector import Vectorization as Vector
from classification import ModelManagement as Manger
import aaaaaa.fileConfig as Conf

# 数据处理合分词
resultDataStream = dataProcess.dataLoadToList(Conf.train_file_path)
result_train_list = dataProcess.participle(resultDataStream[0], Conf.stop_file_path)
#print(result_train_list)

# 文本向量化
model_path = "testModule.model"
module = Vector.word2Vec_train(result_train_list)
module.save(model_path)
result_test_list = dataProcess.participle(dataProcess.dataLoadToList(Conf.test_file_path)[0], Conf.stop_file_path)
result_vector_test_list = Vector.vectorizationWithModel(model_path, result_test_list)
#print(result_test_list)

# 分类模型
"""
result_vector_train_list = [module.docvecs[i] for i in range(len(module.docvecs))]
Manger.trainClassificationModel(result_vector_train_list,resultDataStream[1], "SVM", 0.3,)
"""

# 模型预测
result_vector_train_list = [module.docvecs[i] for i in range(len(module.docvecs))]
model_conf = {"model_name": "SVM", "proportion": 0.3}
manager = Manger()
result = manager.modelPredict(predict_data=result_vector_test_list,
                             train_data=result_vector_train_list,
                             tag=resultDataStream[1],
                             config=model_conf,
                             if_save=True)
